package org.enwey.icarenew.Adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import org.enwey.icarenew.Component.CommentItem;
import org.enwey.icarenew.Model.Comment;

import java.util.List;

/**
 * Created by John on 3/17/2015.
 */
public class CommentAdapter extends BaseAdapter {
    private List<Comment> mCommentList;
    private Context context;

    public CommentAdapter(Context context) {
        this.context = context;
    }
    public void setMenuStyleList(List<Comment> list) {
        this.mCommentList = list;
    }
    @Override
    public int getCount() {
        return (mCommentList != null ? mCommentList.size() : 0);
    }

    @Override
    public Object getItem(int position) {
        return (mCommentList != null ? mCommentList.get(position) : null);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CommentItem commentItem = null;
        if (convertView == null) {
            commentItem = new CommentItem(context);
        }else {
            commentItem = (CommentItem) convertView;
        }

        commentItem.setData(mCommentList.get(position));

        return commentItem;
    }
}
